package com.books.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.books.entity.Book;
import com.books.mapper.BookMapper;
import com.books.service.IBookService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class BookService extends ServiceImpl<BookMapper, Book> implements IBookService {
    @Resource
    private BookMapper bookMapper;

    public int add(Book record) {
        record.setCreatetime(new Date());
        return bookMapper.insert(record);
    }


    public PageInfo<Book> getList(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);

        List<Book> ls = bookMapper.selectList(null);
        PageInfo<Book> pf = new PageInfo<Book>(ls);

        return pf;
    }

}
